/**
 * @author zyj
 * @date 2022年06月10日 10:26
 */
public class Demo2 {
    /**
     * 12A34B
     *
     * @param args
     */
    public static void main(String[] args) {
        Object o = new Object();
        zimu t1 = new zimu(o);
        shuzi t2 =new shuzi(o);
        t2.start();
        t1.start();

    }
}

class zimu extends Thread {
    Object o = new Object();

    public zimu(Object o) {
        this.o = o;
    }

    @Override
    public void run() {
        synchronized (o){
            for (int i = 0; i < 26 ; i++) {
                System.out.println((char) (i+'A'));
                o.notifyAll();
                try {
                    o.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }

        }

    }
}

class shuzi extends Thread {
    Object o = new Object();

    public shuzi(Object o) {
        this.o = o;
    }

    @Override
    public void run() {
        synchronized (o) {
            for (int i = 1; i <= 52; i++) {
                System.out.println(i);
                if (i % 2 == 0) {
                o.notifyAll();
                    try {
                        o.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }

            }
        }
    }
}
